Concurrent access shared buffer in a video encoder

ABSTRACT

A video encoder includes a buffer, a DMA engine, a motion estimator and a motion compensator. The buffer includes four pages where macroblocks are stored. The motion estimator generates a motion vector for a given macroblock. The motion compensator applies the motion vectors generated by the motion estimator to a previously encoded frame. Each of the four pages is concurrently accessed by one of the motion estimator, the motion compensator, and a channel of the DMA engine. Simultaneously the motion compensator accesses one page of the buffer containing a first set of macroblocks, the motion estimator accesses a second page of the buffer containing a second set of macroblocks, a first DMA engine channel writes a different set of macroblocks to a third page of the buffer and a second DMA engine channel writes another set of macroblocks to a fourth page of the buffer.

CROSS-REFERENCE TO RELATED APPLICATION

None.

BACKGROUND

High definition (HD) video comprises numerous macroblocks per frame. For 1080p video, there are 8160 16×16 pixel macroblocks. Thus 8160 macroblocks must be decoded 30 times per second, thereby imposing a significant performance burden on the encoder. Video encoders often are constructed in a pipeline fashion to improve throughput, but additional performance improvements may be desirable.

SUMMARY

Various embodiments are directed to a buffer in a video encoder that is concurrently shared by multiple (e.g., three) entities involved in encoding video. The masters may include, for example, a direct memory access (DMA) engine, a motion estimator, and a motion compensator. By using a buffer that is concurrently accessible by multiple entities, no one entity is forced to wait on access to the buffer. Accordingly, the video encoder operates more efficiently.

Some embodiments are directed to a video encoder that includes a buffer, a DMA engine, a motion estimator and a motion compensator. The buffer includes four pages in which macroblocks of video are stored. The motion estimator generates a motion vector for a given macroblock stored in the buffer. The motion compensator uses the motion vectors to perform interpolation if needed. For a given time slot, each of the four pages is concurrently accessed by one of the motion estimator, the motion compensator, and a channel of the DMA engine. Further, for each such time slot, the motion compensator accesses one page of the buffer containing a first set of macroblocks, while the motion estimator accesses another page of the buffer containing a second set of macroblocks, and while one of the DMA engine channels writes yet a different set of macroblocks to another page of the buffer and another of the DMA engine channels writes another set of macroblocks to another page of the buffer.

Other embodiments are directed to a method that includes writing a first set of macroblocks of video data to a first portion of a shared buffer in a video encoder, performing a search by a motion estimator of a second set of macroblocks of video data in a second portion of the shared buffer, and accessing, by a motion compensator, a third set of macroblocks of video data in a third portion of the shared buffer. The various actions of writing, performing and accessing all occur concurrently.

Still other embodiments are directed to a video encoder that comprises a buffer comprising four pages in which macroblocks of video are stored, a motion estimator to generate a motion vector for a given macroblock stored in the buffer, and a motion compensator to use the motion vectors generated by the motion estimator to perform interpolation. For a given time slot, each of the four pages is concurrently accessible by one of the motion estimator, the motion compensator, and a channel of a direct memory access (DMA) engine.

BRIEF DESCRIPTION OF THE DRAWINGS

For a detailed description of exemplary embodiments of the invention, reference will now be made to the accompanying drawings in which:

FIG. 1 shows a system diagram of a video encoder in accordance with various embodiments;

FIGS. 2A-2D illustrate the use of a buffer by multiple masters to improve performance of a video encoder; and

FIG. 3 shows a method in accordance with a preferred embodiment.

NOTATION AND NOMENCLATURE

Certain terms are used throughout the following description and claims to refer to particular system components. As one skilled in the art will appreciate, companies may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In the following discussion and in the claims, the terms “including” and “comprising” are used in an open-ended fashion, and thus should be interpreted to mean “including, but not limited to . . . .” Also, the term “couple” or “couples” is intended to mean either an indirect or direct connection. Thus, if a first device couples to a second device, that connection may be through a direct connection, or through an indirect connection via other devices and connections.

The term “macroblock” is used herein to represent a group of pixels to be rendered on a display. A macroblock may be a 16×16 group of pixels, but can be a different size and need not be square in other embodiments. A frame of video data is represented by multiple macroblocks.

DETAILED DESCRIPTION

The following discussion is directed to various embodiments of the invention. Although one or more of these embodiments may be preferred, the embodiments disclosed should not be interpreted, or otherwise used, as limiting the scope of the disclosure, including the claims. In addition, one skilled in the art will understand that the following description has broad application, and the discussion of any embodiment is meant only to be exemplary of that embodiment, and not intended to intimate that the scope of the disclosure, including the claims, is limited to that embodiment.

FIG. 1 shows a block diagram of a video encoder 100 in accordance with various embodiments. The encoder 100 includes a motion estimator (ME) 102, a motion compensator (MC) 104, a calculation engine (CALC) 106, an intra-prediction engine 107, an entropy encoder 108, a boundary strength estimator 110, and a loop filter 112. The embodiments discussed herein

The motion estimator 102 and the motion compensator 104 cooperate to provide macroblock inter-frame predictions (i.e., temporal predictions). The motion estimator 102 searches a previous frame for a matching macroblock to each macroblock in a current frame and generates a motion vector for a given macroblock based on a closest match for the macroblock in a previously encoded frame. The ME 102 writes the motion vector at a common offset in buffer 120 agreed upon by the ME 102 and MC 104. The motion compensator 204 applies the motion vector produced by the motion estimator 202 to the previously encoded frame to generate an estimate of the given macroblock.

The intra-prediction engine 107 analyzes a given macroblock with reference to one or more adjacent macroblocks in the same frame. For example, when encoding a given macroblock, the intra-prediction engine 107 may analyze a macroblock directly above (upper macroblock), a macroblock to the right of the upper macroblock (upper right macroblock), a macroblock to the left of the upper macroblock (upper left macroblock), and a macroblock immediately to the left of the given macroblock (left macroblock) to provide spatial predictions. The intra-prediction engine 107 generates a spatial activity metric which it stores in buffer 103. Based on the analysis, the intra-prediction engine 107 selects one of a plurality of intra-prediction modes for application to the given macroblock.

In addition to the motion vector, the ME 102 generates another metric known as the Sum of Absolute Differences (SAD). The SAD is the sum of the absolute differences between pixels in a current macroblock and corresponding pixels in a reference macroblock. The host processor 90 reads the spatial activity metric generated by the intra-prediction engine 107 via buffer 103 and the SAD generated by the ME 102 and performs a mode decision. In the mode decision, the host processor 90 determines whether the current macroblock is to be encoded using either an intra-block encoding technique or an inter-block encoding technique. After making this mode decision, the host processor 90 programs the CALC engine 108 and the entropy encoder 108 to encode each macroblock in accordance with the mode decision made for the macroblock.

In accordance with at least some embodiments of the invention, the intra mode is fixed at 16×16 (one of the four 16×16 modes per the H.264 standard) so that the intra-prediction engine 107 does not have to spend cycles to decide the mode. Further, the intra-prediction engine 107 preferably is programmed to provide a measure of spatial activity of the current block which is used to compare against a SAD of the motion compensated block.

If the mode decision made by the host processor 90 is to inter-block encode a given macroblock, the CALC engine 106 reads interpolated (or motion compensated luminance and chrominance values from a buffer 105 shared between the MC 104 and CALC engine 106. The CALC engine 106 is given a copy of the current macroblock (also referred as the “original” macroblock) by the host processor 90 using the DMA engine 80. The CALC engine 10 takes the difference between motion compensated pixels and current pixels to produce residuals. The residuals will be transformed, quantized, and saved to a buffer 113 shared between the CALC engine 106 and the entropy encoder 108. As quantization is a lossy process (i.e., the precision of the transformed coefficients will be lost when inverse quantization is applied), the CALC engine will produce a reconstructed set of pixels by performing inverse quantization and inverse transformation. The CALC engine 106 will then save the reconstructed pixels in a buffer 111 shared between the CALC engine 106 and the loop filer 112. The reconstructed pixels will be filtered by the loop filter 112 based on the boundary strengths provided by the boundary strength estimator 110. The loop filter 112 saves the filtered data to a buffer 109 which is accessible also by the DMA engine 80.

If the mode decision made by the host processor 90 is to intra-block encode a given macroblock, the CALC engine 106 reads the intra mode and performs intra prediction for the mode for which it has been programmed. The CALC engine 106 computes the difference between intra-predicted pixels and current pixels and produces the residuals. The residuals will be transformed, quantized, and saved into buffer 113. As noted above, quantization is a lossy process and thus the CALC engine will produce a reconstructed set of pixels by performing inverse quantization and inverse transformation. The CALC engine 106 will then save the reconstructed pixels into buffer 111. The reconstructed pixels will be filtered by the loop filter 112 based on the boundary strengths provided by the boundary strength estimator 110. The loop filter 112 saves the filtered data to buffer 109 at the end for the DMA engine 80 to store in external memory.

The entropy encoder 108 receives the transformed quantized residuals, and applies a suitable coding technique. For example, the entropy encoder 108 may apply one of context adaptive binary arithmetic coding and context adaptive variable length coding to produce an entropy encoded macroblock.

The boundary strength estimator 110 assigns strength values to the edges of blocks within the macroblock. For example, the boundary strength estimator 110 may apply strength values to the edges of 4×4 or 8×8 blocks of each macroblock. The strength values may be determined based on, for example, inter-block luminance gradient, size of applied quantization step, and difference in applied coding.

The loop filter 112 receives the strength values provided from the boundary strength estimator 110 and filters the block edges in accordance with the boundary strength values. Each filtered macroblock may be stored for use by the motion estimator 102 and the motion compensator 104 in inter-prediction.

Referring still to FIG. 1, the video encoder 100 also includes a buffer 120 that is shared by the motion estimator (ME) 102 and the motion compensator (MC) 104. Because the buffer 120 is shared by ME 102 and MC 104, the buffer is referred to as an MEMC buffer 120. The MEMC buffer 120 is also shared by a DMA engine 80 and/or a host processor 90. The host processor 90 itself may write video data to the MEMC buffer 120 or program the DMA engine 80 to write video data from storage 84 to the buffer. Thus, the MEMC buffer 120 is accessible by multiple other hardware units (e.g., ME 102, MC 104, DMA engine 80, and host processor 90). In the following discussion, reference is made to the DMA engine 80 writing data to the buffer. References to the DMA engine 80 should be construed as applicable to the host processor 90 as well.

In general, the DMA engine 80 writes macroblock data to the MEMC buffer. The ME 102 then performs a search on that data to determine the closest match of the macroblock to macroblocks of a previous frame. From this search and comparison, the ME 102 generates a motion vector and SAD. The MC 104 fetches the macroblock as indicated by the motion vector to provide to the CALC engine 106 and interpolates the data if necessary.

The MEMC buffer 120 preferably is operated in a “four buffer mode.” Four buffer mode means the MEMC buffer 120 is accessed as four pages. Each page may comprise any desired size such as 8 Kbytes. Each page can be accessed by a different master than the other pages. Thus, the ME 102 can access one page of the MEMC buffer 120, while the MC 104 and DMA engine 80 access other pages of the buffer.

FIGS. 2A-2D illustrate the use of the MEMC buffer 120 at various stages of macroblock processing. The MEMC buffer 120 comprises four concurrently accessible pages designated as MEMC0, MEMC1, MEMC2, and MEMC3 as shown. The ME 102 and MC 104 are able to process four macroblocks of video data a time. The example of FIGS. 2A-2D illustrate the use of the MEMC buffer 120 to process a frame of video starting with the first four macroblocks (macroblocks 0, 1, 2, and 3) and continuing with the next 12 macroblocks 4-15.

Referring first to FIG. 2A, the MEMC buffer 120 initially is empty and the DMA engine 80 writes macroblocks 0-3 to the first page MEMC0 at time slot n. The reference to “DMA” means that the DMA engine 80 is the master of that particular page and wrote the data to the page. The reference to “Luma” means that only the luminance values of the macroblock were written by the DMA engine. In accordance with the preferred embodiments, the ME's search algorithm only searches luminance data, not chrominance data, based on the assumption that motion effects the chrominance data generally the same as the luminance data and thus only luminance data need be searched. The reference to “ORG” refers to the current (original) macroblocks being encoded and “REF” refers to the macroblocks from a previous frame that are used as reference macroblocks for the motion estimation algorithm.

FIG. 2B represents the state of the MEMC buffer at time slot n+2. The DMA engine 80 writes the next four macroblocks (macroblocks 4-7) to MEMC1. The data written by the DMA engine 80 preferably is, as was the case in FIG. 2A, only the luminance values for the current (ORG) and reference (REF) macroblocks 4-7. While the DMA engine is writing the luminance data for macroblocks 4-7, the ME 102 accesses the first four macroblocks 0-3 in MEMC0 previously written there by the DMA engine 80 at time slot n as explained above with regard to FIG. 2A. The ME 102 performs its searching algorithm on the luminance values of macroblocks 0-3.

In FIG. 2C (time slot n+4), the DMA engine 80 writes the luminance values for the next set of macroblocks 8-11 to MEMC2, while the ME 102 accesses the previously written luminance values in MEMC1 (for macroblocks 4-7) to perform its searching algorithm. The DMA engine 80 preferably has multiple DMA channels and, while one DMA channel is used to write the ORG and REF macroblocks 8-11 to MEMC2, another DMA channel is used to overwrite the ORG luminance data in MEMC0 with chrominance values (“Chroma”) of the reference macroblocks for macroblocks 0-3. Thus, in FIG. 2C, MEMC0 will contain luminance and chrominance data for the reference macroblocks for macroblocks 0-3. The ORG luminance data for macroblocks 0-3 is no longer needed at this point in the preferred embodiments, and thus can be overwritten without penalty.

FIG. 2D represents the state of the MEMC buffer 120 at time slot n+6. The DMA engine 80 writes luminance values for the ORG and REF macroblocks 12-15 to MEMC3, while the ME 102 performs its searching algorithm on the previously written luminance values in MEMC2 (macroblocks 8-11). At the same time, the DMA engine 80 also writes chrominance values for the reference macroblocks for macroblocks 4-7 into MEMC1. As explained above, the DMA engine 80 overwrites the previously written ORG luminance values in MEMC1 with the newly written REF chrominance values for macroblocks 4-7. The MC 104 accesses MEMC0 to perform interpolation as necessary. The MC 104 may also apply specific weights to the pixels during interpolation as provided by, for example, the host processor 90.

FIG. 2D illustrates that three different masters including the DMA engine 80 (two channels), ME 102, and MC 104 access different pages of the MEMC buffer 120. The buffer 120 preferably is a circular buffer and in the next time slot n+8 (which is not shown), DMA engine 80 will cycle back around and write ORG and REF luminance values for macroblocks 16, 17, 18, and 19 to MEMC0, while ME 102 searches macroblock data in MEMC3 (macroblocks 12-15), the DMA engine also writes chrominance REF values for macroblocks 8-11, and the MC 104 advances to MEMC1. As such, the various masters involves in the data writing, motion estimation and motion compensation process are not forced to wait for access to the buffer, as otherwise would have been the case if, for example, a two buffer mode had been used for MEMC 120.

FIG. 3 illustrates a method in accordance with embodiments of the invention. The various actions depicted in FIG. 3 preferably are all performed concurrently. At 202, a first set of macroblocks is written to a first portion of the MEMC buffer. This action may represent, for example, the DMA engine 80 writing luminance only values to one of the MEMC pages as explained above. At 204, the method comprises performing a search by the ME 102 of a second set of macroblocks in a second portion of the shared MEMC buffer 120. This action may represent the ME searching luminance data previously written by the DMA engine 80. At 206, the method includes accessing a third set of macroblocks in a third portion of the MEMC buffer by MC 102. At 208, the method includes writing a fourth set of macroblocks to a fourth proportion of the MEMC buffer. This action may represent the DMA engine writing chrominance values corresponding to the reference macroblocks.

The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications. 

1. An apparatus, comprising: a buffer comprising four pages in which macroblocks of video are stored; a direct memory access (DMA) engine comprising a plurality of channels, each DMA channel to write encoded macroblocks to the buffer; a motion estimator to generate a motion vector for a given macroblock stored in the buffer; and a motion compensator to use the motion vectors generated by the motion estimator to perform interpolation; wherein, for a given time slot, each of the four pages is concurrently accessed by one of the motion estimator, the motion compensator, and a channel of the DMA engine; wherein for each such time slot, the motion compensator accesses one page of the buffer containing a first set of macroblocks, while the motion estimator accesses another page of the buffer containing a second set of macroblocks, and while one of the DMA engine channels writes yet a different set of macroblocks to another page of the buffer and another of the DMA engine channels writes another set of macroblocks to yet another page of the buffer.
 2. The apparatus of claim 1 wherein the buffer is implemented as a circular buffer and wherein each of the DMA engine channels, motion estimator, and motion compensator accesses a next page in the buffer with each consecutive time slot.
 3. The video encoder of claim 1 wherein a first DMA engine channel writes luminance data for a current frame and for a reference frame to one page of the buffer at any given time slot.
 4. The apparatus of claim 3 wherein a second DMA engine channel overwrites a current frame's luminance data with a reference frame's chrominance data at any given time slot.
 5. The apparatus of claim 3 wherein the motion estimator generates motion vectors based on only luminance values stored in one page of the buffer, while the motion compensator performs interpolation on both luminance and chrominance values stored in another page of the buffer.
 6. The apparatus of claim 1 wherein each of the motion estimator, motion compensator, and the DMA channels rotates their usage of the pages of the buffer with successive time slots.
 7. A method usable in a video encoder, comprising: writing a first set of macroblocks of video data to a first portion of a shared buffer in a video encoder; performing a search by a motion estimator of a second set of macroblocks of video data in a second portion of the shared buffer; and accessing, by a motion compensator, a third set of macroblocks of video data in a third portion of the shared buffer; wherein the writing, performing and accessing occur concurrently.
 8. The method of claim 7 further comprising writing a fourth set of macroblocks of video data to a fourth portion of the shared buffer, wherein writing the first and fourth sets of macroblocks, performing, and accessing all occur concurrently.
 9. The method of claim 7 wherein writing the first set of macroblocks comprises writing only luminance values of the first set of macroblocks and wherein writing the fourth set of macroblocks comprises writing chrominance values of reference macroblocks.
 10. A video encoder, comprising: a buffer comprising four pages in which macroblocks of video are stored; a motion estimator to generate a motion vector for a given macroblock stored in the buffer; and a motion compensator to use the motion vectors generated by the motion estimator to perform interpolation; wherein, for a given time slot, each of the four pages is concurrently accessible by one of the motion estimator, the motion compensator, and a channel of a direct memory access (DMA) engine.
 11. The video encoder of claim 10 wherein for each such time slot, each page of the buffer is accessed the motion compensator accesses one page of the buffer containing a first set of macroblocks, while the motion estimator accesses another page of the buffer containing a second set of macroblocks, and while one of the DMA engine channels writes yet a different set of macroblocks to another page of the buffer and another of the DMA engine channels writes another set of macroblocks to yet another page of the buffer.
 12. The video encoder of claim 1 wherein the buffer is implemented as a circular buffer. 